package com.jtpay.sdk.activity;

import android.text.TextUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by Steven on 2016/8/30 0030.
 */
public class TokenParam implements Serializable {
    private String mUserCode;
    private String mOrder;
    private String mMoney;
    private String mReturnUrl;
    private String mNotifyUrl;
    private String mOrderTime;
    private String mMethod;
    private String mSign;

    public String getUserCode() {

        return mUserCode;
    }

    public String getOrder() {
        return mOrder;
    }

    public String getMoney() {
        return mMoney;
    }

    public String getReturnUrl() {
        return mReturnUrl;
    }

    public String getNotifyUrl() {
        return mNotifyUrl;
    }

    public String getOrderTime() {
        return mOrderTime;
    }

    public String getMethod() {
        return mMethod;
    }

    public String getSign() {
        return mSign;
    }

    public TokenParam(String userCode, String order, String money, String returnUrl, String notifyUrl, String orderTime, String method, String sign) {
        mUserCode = userCode;
        mOrder = order;
        mMoney = money;
        mReturnUrl = returnUrl;
        mNotifyUrl = notifyUrl;
        mOrderTime = orderTime;
        mMethod = method;
        mSign = sign;
    }
    public JSONObject getTokenParams() throws JSONException {
        JSONObject object = new JSONObject();
        if (!TextUtils.isEmpty(mUserCode))
            object.put("p1_usercode", mUserCode);
        if (!TextUtils.isEmpty(mOrder))
            object.put("p2_order", mOrder);
        if (!TextUtils.isEmpty(mMoney))
            object.put("p3_money", mMoney);
        if (!TextUtils.isEmpty(mReturnUrl))
            object.put("p4_returnurl", mReturnUrl);
        if (!TextUtils.isEmpty(mNotifyUrl))
            object.put("p5_notifyurl", mNotifyUrl);
        if (!TextUtils.isEmpty(mOrderTime))
            object.put("p6_ordertime", mOrderTime);
        if (!TextUtils.isEmpty(mSign))
            object.put("p7_sign", mSign);

        return object;

    }
}
